/*
 * @Author: nns4
 * @Date: 2019-12-03 11:19:59
 * @LastEditors: nns4
 * @LastEditTime: 2019-12-03 11:20:11
 * @FilePath: /wxShop/src/store/module/test.js
 * @Description:  vuex demo
 */
export default {
    state: {
        userName: 'zhaolitong'
    },
    mutations: {
        changeName(state, data) {
            return state.userName = data
        }

    },
    getters: {
        nameLength: (state) => {
            return state.userName.length
        },
        addname: (state) => (id) => {
            return state.userName + '----传过去的参数是----' + id
        },
        getName:(state)=>{
            return state.userName
        }
    },
    actions: {
        actionA: ({
            commit,
            state
        }, math) => {
            setTimeout(()=>{
                commit("changeName",state.userName+"--- action--"+ math)
            },1000)
          
        }
    }
}